package com.foreknow.penTest;

import java.util.*;

/**
 * @author shkstart
 * @create 2021-08-18 19:30
 */
public class SubCharNum {
    public static void main(String[] args) {
        String str="afgasdasda";
        int num=0;//记录个数
        List<Character> list=new ArrayList<>();
        Set<Character> set=new HashSet();

        for (int i = 0; i < str.length(); i++) {
            set.add(str.charAt(i));
        }

            Iterator<Character> iterator = set.iterator();
        while (iterator.hasNext()){
            Character next = iterator.next();
            for (int i = 0; i < str.length(); i++) {
                if(next.equals(str.charAt(i))){
                    num++;
                }

            }
            System.out.println(next+"----"+num);
            num=0;

        }

    }
}
